﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DomainDriver.CommonUtilities.Collections
{
    public class UntypedEqualityComparer<T> : IEqualityComparer<object>
    {
        private IEqualityComparer<T> m_TypedComparer;

        public UntypedEqualityComparer(IEqualityComparer<T> typedComparer)
        {
            if (typedComparer == null)
            { throw new InvalidOperationException("The specified IEqualityComparer was null."); }

            m_TypedComparer = typedComparer;
        }

        public IEqualityComparer<T> TypedComparer
        {
            get { return m_TypedComparer; }
        }

        public bool Equals(object x, object y)
        {
            return m_TypedComparer.Equals((T)x, (T)y);
        }

        public int GetHashCode(object obj)
        {
            return m_TypedComparer.GetHashCode((T)obj);
        }
    }
}